/***********************************************************************
 * Module:  Project.java
 * Author:  Administrator
 * Purpose: Defines the Class Project
 ***********************************************************************/
package com.sogoodsoft.entity.project;

import java.util.ArrayList;
import java.util.Iterator;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.sogoodsoft.entity.IdEntity;
import com.sogoodsoft.entity.account.User;
import com.sogoodsoft.entity.app.Organization;
import com.sogoodsoft.entity.app.SysClass;

/** 项目 */
@Entity
@Table(name = "PROJECT")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Project extends IdEntity {

    /** 项目名称 */
    public java.lang.String prjName;

    /** 项目简称 */
    public java.lang.String shortName;

    /** 申请日期 */
    public java.util.Date applyDate;

    /** 备注 */
    public java.lang.String note;

    /** 项目概要说明 */
    public java.lang.String summarize;

    /** 总共要通过的审核数 */
    public Long total = new Long(1);

    /** 已通过的审核数 */
    public Long already = new Long(0);

    public java.util.List < PrjFile > prjFile;

    public java.util.List < Assessment > assessments = new ArrayList < Assessment >();

    public Organization organization;

    public SysClass sysClass;

    public User user;

    /** @pdGenerated default getter */

    /** @pdGenerated default iterator getter */
    @SuppressWarnings("rawtypes")
    @Transient
    public Iterator getIteratorPrjfile() {
        if (prjFile == null)
            prjFile = new java.util.ArrayList < PrjFile >();
        return prjFile.iterator();
    }

    /**
     * @pdGenerated default remove
     * @param oldPrjfile
     */
    public void removePrjfile(PrjFile oldPrjfile) {
        if (oldPrjfile == null)
            return;
        if (this.prjFile != null)
            if (this.prjFile.contains(oldPrjfile)) {
                this.prjFile.remove(oldPrjfile);
                oldPrjfile.setProject((Project) null);
            }
    }

    /** @pdGenerated default removeAll */
    @SuppressWarnings("rawtypes")
    public void removeAllPrjfile() {
        if (prjFile != null) {
            PrjFile oldPrjfile;
            for (Iterator iter = getIteratorPrjfile(); iter.hasNext();) {
                oldPrjfile = (PrjFile) iter.next();
                iter.remove();
                oldPrjfile.setProject((Project) null);
            }
        }
    }

    @Column(name = "PRJ_NAME")
    public java.lang.String getPrjName() {
        return prjName;
    }

    public void setPrjName(java.lang.String prjName) {
        this.prjName = prjName;
    }

    @Column(name = "SHORT_NAME")
    public java.lang.String getShortName() {
        return shortName;
    }

    public void setShortName(java.lang.String shortName) {
        this.shortName = shortName;
    }

    @Column(name = "APPLY_DATE")
    public java.util.Date getApplyDate() {
        return applyDate;
    }

    public void setApplyDate(java.util.Date applyDate) {
        this.applyDate = applyDate;
    }

    public java.lang.String getNote() {
        return note;
    }

    public void setNote(java.lang.String note) {
        this.note = note;
    }

    public java.lang.String getSummarize() {
        return summarize;
    }

    public void setSummarize(java.lang.String summarize) {
        this.summarize = summarize;
    }

    @OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
    @OrderBy("id asc")
    public java.util.List < PrjFile > getPrjFile() {
        return prjFile;
    }

    @OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
    @OrderBy("id asc")
    public java.util.List < Assessment > getAssessments() {
        return assessments;
    }

    public void setAssessments(java.util.List < Assessment > assessments) {
        this.assessments = assessments;
    }

    public void setPrjFile(java.util.List < PrjFile > prjFile) {
        this.prjFile = prjFile;
    }

    @ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE }, optional = true)
    @JoinColumn(name = "APPLY_UNIT_ID")
    public Organization getOrganization() {
        return organization;
    }

    public void setOrganization(Organization organization) {
        this.organization = organization;
    }

    @ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE }, optional = true)
    @JoinColumn(name = "SYS_ID")
    public SysClass getSysClass() {
        return sysClass;
    }

    public void setSysClass(SysClass sysClass) {
        this.sysClass = sysClass;
    }

    @ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE }, optional = true)
    @JoinColumn(name = "APPLY_USER_ID")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Long getAlready() {
        return already;
    }

    public void setAlready(Long already) {
        this.already = already;
    }

}